import { Slider} from "antd";
import {CommonComponentProps} from "../../../../components/editor/interface.ts";
import {useDrag} from "react-dnd";
import FormItem from "antd/es/form/FormItem";
import {CSSProperties} from "react";
import {removeSetter} from "../../../utils/removeSetter.ts";
import {MoveDrop} from "../../../hooks/useMoveDrop.tsx";

export interface SliderProps extends CommonComponentProps {
    id: number;
    name: string;
    styles?: CSSProperties;
    parentId: number;
    children?: any;
    max:number
    min:number
    step:number
    disabled:boolean
    range:boolean
    reverse:boolean
    vertical:boolean
}

const SliderDev = (props:SliderProps) => {
    const {id,name,styles} = props

    const [_,drag] = useDrag({
        type:'Slider',
        item:{
            id,
            type:name,
            dragType:"move",
        }
    })
    const ComponentProps = removeSetter({...props},["children","parentId"])

    return (
        <div className={'relative'}  data-component-id={id} ref={drag}>
            <MoveDrop key={name} dropComponentId={id} parentId={props.parentId}  />
            <FormItem>
                <FormItem label={props.label} name={props.name} rules={props.rule} style={{margin: "0"}}>
                    <Slider {...ComponentProps} style={{height:styles?.height,...styles}} />
                </FormItem>
            </FormItem>
        </div>
    );
};

export default SliderDev;